29 pydeck
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# !pip install leafmap
# !pip install leafmap
In [2]:
Copied!
import leafmap.deck as leafmap
import leafmap.deck as leafmap
Create an interactive map.
In [3]:
Copied!
m = leafmap.Map(center=(40,-100), zoom=3)
m
m = leafmap.Map(center=(40,-100), zoom=3)
m
Out[3]:
Add basemap.
In [4]:
Copied!
m = leafmap.Map()
m.add_basemap("HYBRID")
m
m = leafmap.Map()
m.add_basemap("HYBRID")
m
Out[4]:
Add vector data to the map. It supports any GeoPandas supported format, such as GeoJSON, shapefile, KML.
In [5]:
Copied!
m = leafmap.Map()
filename = "https://github.com/giswqs/streamlit-geospatial/raw/master/data/us_states.geojson"
m.add_vector(filename, random_color_column="STATEFP")
m
m = leafmap.Map()
filename = "https://github.com/giswqs/streamlit-geospatial/raw/master/data/us_states.geojson"
m.add_vector(filename, random_color_column="STATEFP")
m
Out[5]:
Add a GeoPandas GeoDataFrame to the map.
In [6]:
Copied!
import geopandas as gpd
import geopandas as gpd
In [7]:
Copied!
url = "https://github.com/giswqs/streamlit-geospatial/raw/master/data/us_counties.geojson"
gdf = gpd.read_file(url)
url = "https://github.com/giswqs/streamlit-geospatial/raw/master/data/us_counties.geojson"
gdf = gpd.read_file(url)
In [8]:
Copied!
m = leafmap.Map()
m.add_gdf(gdf, random_color_column="STATEFP")
m
m = leafmap.Map()
m.add_gdf(gdf, random_color_column="STATEFP")
m
Out[8]:
Create a 3D view of the map. Press Ctrl and hold down the left mouse button to rotate the 3D view.
In [9]:
Copied!
initial_view_state={"latitude": 40, "longitude": -100, "zoom": 3, "pitch": 45, "bearing": 10}
m = leafmap.Map(initial_view_state=initial_view_state)
filename = "https://github.com/giswqs/streamlit-geospatial/raw/master/data/us_states.geojson"
m.add_vector(filename, random_color_column="STATEFP", extruded=True, get_elevation="ALAND", elevation_scale=0.000001)
m
initial_view_state={"latitude": 40, "longitude": -100, "zoom": 3, "pitch": 45, "bearing": 10}
m = leafmap.Map(initial_view_state=initial_view_state)
filename = "https://github.com/giswqs/streamlit-geospatial/raw/master/data/us_states.geojson"
m.add_vector(filename, random_color_column="STATEFP", extruded=True, get_elevation="ALAND", elevation_scale=0.000001)
m
Out[9]:

Last update:
2022-01-22